/**
 * @author Steve Cox
 * @date 10/19/2011
 * @description controller for the Implant Medical Center page of the Thoratec
 * Digital Hub project. This page lists the implants for a specified patient.
*/
public with sharing class MM_ImplantMedicalCenterController {
   private final static Integer IMPLANT_THIS_PAGE = 3;

   //-----------------------------------------------------------------------
   // Instance variables
   public Patient__c patient;
   public List<MM_OrderedImplant> implantList;
   private String fields = 'Implanting_Center__c,Surgeon__c';

   public MM_ImplantMedicalCenterController(ApexPages.StandardController parentController) {
      patient = (Patient__c)parentController.getRecord();
      this.refreshImplants();
   }

   public List<MM_OrderedImplant> implants {
      get { return implantList; }
   }

   public void save() {
      MM_OrderedImplant.updatePatientImplants(implantList);
      this.refreshImplants();
   }

   public void cancel() {
      this.refreshImplants();
   }

   public String getFormPage() {
      return MM.format(Label.MM_ImplantFormPage, IMPLANT_THIS_PAGE, MM.IMPLANT_PAGES);
   }

   private void refreshImplants() {
      implantList = MM_OrderedImplant.getPatientImplants(patient.Id, fields);
   }
}